import { Action } from './action'

const actions = {}
export const setAction = (key, viewer, cesium) => {
  actions[key] = new Action(viewer, cesium)
  return actions[key]
}
export const getAction = (key, arg) => {
  return new Promise((resolve) => {
    const timer = setInterval(() => {
      if (actions[key]) {
        resolve(arg ? actions[key][arg] : actions[key])
        window.clearInterval(timer)
      }
    }, 100)
  })
}
export const delAction = (key) => {
  delete actions[key]
}
